<template>
	<view  class="container" style="width: 100%;">
		<view class="evan-form-show">
			<sl-list :lists='lists' @onInput="onInput"></sl-list>
		</view>
	
		
		<view style="padding: 20rpx 30rpx;">
			上传凭证
			<tui-upload :serverUrl="serverUrl" :formData="formData"  @complete="result" :limit='5'></tui-upload>
		</view>
		
		<view class="btn-box">
		 	<button class="submit-btn" type="primary" @click="doSubmit">提 交</button>
		</view>
	</view>
</template>

<script>
	import tuiUpload from '@/components/thor-ui/tui-upload/tui-upload'
	import slList from '@/components/sl-ui/sl-tamp/sl-list.vue'
	import config from '@/config/config'
	export default {
		components:{tuiUpload,slList},
		
		data() {
			return {
				order_no:"",
				type:"",
				order_money:0,
				lists: [
					{
						type:"select",
						name: '退款原因',
						value:"",
						placeholder:"请选择",
						showArrow:true,
						textAlign:'right',
						req:true,
						itemList:[
							{text: "我不想要了"},
							{text: "商品描述不符"},
							{text: "少件、漏发"},
							{text: "包装，商品不符"},
							{text: "卖家发错货"},
							{text: "其他"}
						]
					},
					{
						name: '退款金额',
						value:"￥123",
						placeholder:"请输入金额",
						showArrow:false,
						textAlign:'right',
						disabled:true,
						req:true,
						color:'#D9522D'
					},
					{
						type:"textarea",
						name: '退款说明',
						value:"",
						req:true,
						placeholder:"请输入说明",
						showArrow:false
					},
				],
				//上传地址
				serverUrl:config.effectiveUrl() + "/app/soft/upload/upload",
				formData:{
					fkGuid: this.order_no,
					ywName:'订单管理',
					fkType:'售后'
				},
				imageData: [],
			}
		},
		computed:{
			
		},
		onLoad(opt) {
			this.order_no = opt.order_no;
			this.formData.fkGuid = opt.order_no;
			this.type = opt.type == 1 ? '退款退货' : '退款无需退货';
			this.order_money =  opt.order_money;
			this.lists[1].value = '￥' + opt.order_money;
		},
		methods: {
			onInput(value,index) {
				this.lists[index].value = value;
			},
			result: function(e) {
				this.imageData = e.imgArr;
			},
			// 提交
			doSubmit(){
				if(!this.lists[0].value){
					return this.$util.msg('请选择退款原因');
				}
				if(!this.lists[1].value){
					return this.$util.msg('退款金额不能为空');
				}
				if(!this.lists[2].value){
					return this.$util.msg('退款说明不能为空');
				}
				this.$request("/app/v1/Order/refundApply",{
					order_no: this.order_no,
					type:this.type,
					reason: this.lists[0].value,
					money:this.order_money,
					remarks:this.lists[2].value
				}).then(res=>{
					uni.redirectTo({url:"/pages/success/success"});
				});
				
			}
		},
	
	}
</script>
	
<style lang='scss'>
	.btn-box{
		position: fixed;
		bottom: 0;
		width: 100%;
		left:0;
		right: 0;
		button{
			width: 100%;
			height: 85upx;
			border-radius: 0;
			font-size: $uni-font-size-base;
			background-color:$base-color;
			line-height: 85upx
		}
	}
</style>
